package bsh;

import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.FieldVisitor;

/**
 * FieldVisitor that visits two other {@link FieldVisitor}'s
 * 
 * @author takeshi
 */
public class DoubleFieldVisitor implements FieldVisitor {
    private final FieldVisitor fv1, fv2;

    /**
     * Ctor
     * 
     * @param fv1 {@link FieldVisitor}
     * @param fv2 other {@link FieldVisitor}
     */
    public DoubleFieldVisitor(FieldVisitor fv1, FieldVisitor fv2) {
        this.fv1 = fv1;
        this.fv2 = fv2;
    }

    /**
     * {@inheritDoc}
     */
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
        return new DoubleAnnotationVisitor(this.fv1.visitAnnotation(desc, visible), this.fv2.visitAnnotation(desc, visible));
    }

    /**
     * {@inheritDoc}
     */
    public void visitAttribute(Attribute attr) {
        this.fv1.visitAttribute(attr);
        this.fv2.visitAttribute(attr);
    }

    /**
     * {@inheritDoc}
     */
    public void visitEnd() {
        this.fv1.visitEnd();
        this.fv2.visitEnd();
    }
}
